package ZhujieTest;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Date;

public class test {

    public static void main(String args[]) throws IllegalAccessException, InstantiationException, InvocationTargetException {
        Class cl = zhujie.class;
        Method[] methods = cl.getMethods();

        for (Method method : methods) {
             boolean hasTime = method.isAnnotationPresent(Time.class);
             if (hasTime) {
                 Time annotation = method.getAnnotation(Time.class);
                 long start = new Date().getTime();
                 method.invoke(cl.newInstance(),null);
                 long time = new Date().getTime()-start;
                 if(annotation.timeLong()<=time){
                    System.out.println("运行时间："+time+"ms");
                 }
            }
        }
    }
}
